<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/29
 * Time: 20:55
 */
include "config.php";
if($_SERVER["REQUEST_METHOD"] == "POST"){
    $unameLength= mb_strlen($_POST["uname"],"utf-8");
    $upwdLength= mb_strlen($_POST["upwd"],"utf-8");
    if(isset($_POST["uname"]) && isset($_POST["upwd"])){
        $UNAME = $_POST["uname"];
        $UPWD = $_POST["upwd"];
        $sqllogin = "SELECT * FROM userinfo WHERE u_name='" . $UNAME . "' AND u_pwd='" . $UPWD . "';";
        $result = $conn->query($sqllogin);
        if($result->num_rows >= 1){
            print_r(json_encode(Array("status"=>1,"msg"=>"登录成功")));
        } else {
            print_r(json_encode(Array("status" => 0, "msg" => "用户名或密码错误")));
        }

        $conn->close();
    }else{
        print_r(json_encode(Array("status" => -2, "msg" => "用户名或密码不能为空")));
    }
} else {
    print_r(json_encode(Array("status" => -1, "msg" => "不支持get请求")));
}